<template>
  <el-date-picker class="w100 w-max100" v-bind="$attrs" v-model="model" :format="format" :value-format="valueFormat" />
</template>

<script>
  export default {
    name: 'bDatePicker',
    props: {
      formValue: {
        type: [String, Number]
      },
      field: {
        type: String,
        default: ''
      }
    },
    computed: {
      model: {
        get() {
          return this.formValue
        },
        set(val) {
          this.$emit('changeData', { key: this.field, value: val, event: 'change' })
        }
      },
      format() {
        return this.$attrs.format || 'yyyy-MM-dd'
      },
      valueFormat() {
        return this.$attrs.valueFormat || this.$attrs['value-format'] || 'yyyy-MM-dd'
      }
    }
  }
</script>
